<?php include "counter.php" ?>
<html>
<?php pagehead("Most Penguin-Friendly Place Competition") ?>
<?php
  $poplimit = $counter->get_input('poplimit', 'number', 'get|post');
  if (!$poplimit) {
      $poplimit = 1;
  }
  # the counter works with millions...
  $mlimit = $poplimit / 1000000;
?>
<body>
<?php pagetop() ?>
<table width=95%>
   <tr>
       <td><h1><img src="/gifs/Logo-small.png" alt="Linux Counter Logo">Penguin Friendly Places</h1></td>
       <td align="right">
       Places with more than:
       <ul>
           <li><a href="./citystat.php?poplimit=1000">1000 people</a>
           <li><a href="./citystat.php?poplimit=10000">10.000 people</a>
           <li><a href="./citystat.php?poplimit=100000">100.000 people</a>
           <li><a href="./citystat.php?poplimit=1000000">1.000.000 people</a>
           <li><a href="./citystat.php?poplimit=1">No limit</a>
       </ul>
       </td>
   </tr>
</table>
This page gives a list of the 100 places where Linux is the Most Used System!
<p>
A place is entered here when:
<ul>
    <li>It has more than 5 Linux users
    <li>The <a href="maintainers.php">maintainer</a> for that area has entered its population.
    <li>There are more than <?php echo $poplimit. ($poplimit > 1 ? " people" : " person"); ?> there
</ul>
At <span id="gmtime"><?php echo gmstrftime ("%b %d %Y %H:%M:%S",time())."\n"; ?> GMT, the following cities/states/countries are in the lead:<br>
<table border>
   <tr>
       <th>#</th>
       <th>Name</th>
       <th>Type</th>
       <th>Population</th>
       <th>Users</th>
       <th>Density</th>
   </tr>
<?php
 $query = mysql_query("select p.longname, p.type, p.population, p.users, p.users/p.population as density, p.name, pp.longname, ppp.longname as ppplongname from places as p, places as pp left join places as ppp on (pp.within = ppp.f_key) where p.population > $mlimit and p.users > 5 and p.within = pp.f_key order by density desc limit 100");
 $index = 0;
 while ($arr = mysql_fetch_row($query)) {
    $index += 1;
    $recname = $arr[5];
    if ($arr[1] == 'country') {
        $printname = $arr[0];
    } elseif($arr[7] == 'The World' || $arr[7] == 'NULL') {
        $printname =  $arr[0] . ", " . $arr[6];
    } else {
        $printname = $arr[0] . ", " . $arr[6] . ", " . $arr[7] ;
    }
?>
   <tr>
       <td><?php echo $index; ?></td>
       <td><?php echo place_page($recname, $printname); ?></td>
       <td><?php echo $arr[1]; ?></td>
       <td align="right"><?php echo number_format($arr[2] * 1000000, 0, ".", " "); ?></td>
       <td align="right"><?php echo $arr[3]; ?></td>
       <td align="right"><?php echo number_format($arr[4], 2); ?></td>
   </tr>
<?php
 }
?>
</table>
<h2><a href="/enter-person.php">Get counted!</a></h2>
<?php pagebottom() ?>
</body>
</html>

